/*
 * Copyright (C) 2009 M. Hautle.
 * 
 * This file is part of TrackedBean.
 * 
 * TrackedBean is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * TrackedBean is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License along with TrackedBean. If not, see <http://www.gnu.org/licenses/>.
 */
package ch.trackedbean.copier.annotations;

import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.*;
import java.lang.annotation.*;
import java.util.*;
import ch.trackedbean.copier.*;

/**
 * Annotation defining that the annotated {@link List} has to be mapped.<br>
 * <b>This mapping supports only source to destination conversion, the other way round no operation will be executed!</b><br>
 * Use this annotation for lists holding beans which should be converted into other beans.<br>
 * The {@link BeanMapperManager} will be used to get a corresponding {@link IBeanMapper} to convert the source beans.<br>
 * A new {@link List} will be instanciated if the destination property is <code>null</code> and the source property self is not <code>null</code>. If there is
 * allready a {@link List} in the destination property then the converted value will be appended.<br>
 * Consider to use {@link ListMapping} if possible.<br>
 * Use {@link Mappings} if you need more than one such mapping on the same property.
 * 
 * @author M. Hautle
 */
@Documented
@Target( { METHOD, FIELD })
@Retention(RUNTIME)
public @interface ListPathMapping {
	/** The path to the source property (as simple EL expression). */
	String path();

	/** The <b>bean type</b> where the given {@link #path()} ends (so the class holding the desired property). */
	Class<?> lastPathType();

	/** The destination type. (So the type to which the source list members will be converted). Either {@link #srcEvaluator()} or this field must be set. */
	Class dstType() default Object.class;

	/**
	 * The class from which the attribute get's copied. (If not specified the one specified in {@link SourceClass} will be assumed)
	 */
	Class<?> srcClass() default Object.class;

	/** The type evaluator to use for {@link IBeanMapper#copySrc2Dst(Object, Object, IMappingContext)}. Either {@link #srcClass()} or this field must be set. */
	Class<? extends ITypeEvaluator> srcEvaluator() default ITypeEvaluator.class;
}
